/*
 * 处理local、session存储的数据
 */

export default {
  get(name) {
    try {
      return JSON.parse(localStorage.getItem(name));
    } catch {
      return localStorage.getItem(name);
    }
  },
  set(name, value) {
    localStorage.setItem(name, JSON.stringify(value));
  },
  remove(name) {
    localStorage.removeItem(name);
  },
  clear() {
    localStorage.clear();
  },
  s_get(name) {
    try {
      return JSON.parse(sessionStorage.getItem(name));
    } catch {
      return sessionStorage.getItem(name);
    }
  },
  s_set(name, value) {
    sessionStorage.setItem(name, JSON.stringify(value));
  },
  s_remove(name) {
    sessionStorage.removeItem(name);
  },
  s_clear() {
    sessionStorage.clear();
  }
};
